package cn.zhz.dao;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


public class HibernateUtil {
    private static Configuration configuration;
    private final static SessionFactory sessionFactory;

    static {
        try {
            configuration=new Configuration().configure();
            sessionFactory=configuration.buildSessionFactory();
        } catch (HibernateException e) {
            throw new ExceptionInInitializerError(e);
        }
    }

    private HibernateUtil(){}

    public  static Session currentSession(){
        return sessionFactory.getCurrentSession();
    }
}
